<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>朗读亭--配置编辑</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<style>
.btn {
    border-radius: 3px;
    -webkit-box-shadow: none;
    box-shadow: none;
    border: 1px solid transparent;
}
.btn-primary {
    color: #fff;
    background-color: #337ab7;
    border-color: #2e6da4;
}
.btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
}
.btn-success {
    color: #fff;
    background-color: #5cb85c;
    border-color: #4cae4c;
}
</style>
</head>
<body>
	<section class="content-header">
      <h1>
        系统管理
        <small>配置管理</small>
      </h1>
    </section>
	<section class="content">
	<div style="width:100%;margin-top:10px;border: 1px solid #000;">
		<div style="width:100%;margin-top:3px;">
			<form id="typeForm">
			<input type="hidden" name="id" id="id" value="${config.id }" />
			<table style="width:100%;">
				<tr>
					<td class="text-right">机构名称：</td>
					<td><input type="text" name="title" id="title" value="${config.title }"/></td>
				</tr>
				<tr>
					<td class="text-right">页面风格：</td>
					<td><select name="style">
						<option value="1" <c:if test="${config.style=='1' }">selected</c:if>>风格1</option>
						<option value="2" <c:if test="${config.style=='2' }">selected</c:if>>风格2</option>
						<option value="3" <c:if test="${config.style=='3' }">selected</c:if>>录制音频</option>
						<option value="4" <c:if test="${config.style=='4' }">selected</c:if>>录制视频</option>
					</select></td>
				</tr>
				<tr>
					<td class="text-right">免费次数：</td>
					<td><input type="number" name="freetimes" id="freetimes" value="${config.freetimes }"/></td>
				</tr>
				<tr>
					<td class="text-right">微信appid：</td>
					<td><input type="text" name="appid" id="appid" value="${config.appid }"/></td>
				</tr>
				<tr>
					<td class="text-right">微信appsecret：</td>
					<td><input type="text" name="appsecret" id="appsecret" value="${config.appsecret }"/></td>
				</tr>
				<tr>
					<td class="text-right">微信授权token：</td>
					<td><input type="text" name="token" id="token" value="${config.token }"/></td>
				</tr>
				<tr>
					<td class="text-right">续读费用：</td>
					<td><input type="text" name="continue_fee" id="continue_fee" value="${config.continue_fee }"/></td>
				</tr>
				<tr>
					<td class="text-right">音乐数量：</td>
					<td><input type="text" name="bgmusic" id="bgmusic" value="${config.bgmusic }"/></td>
				</tr>
				<tr>
					<td class="text-right">底部信息：</td>
					<td><textarea rows="8" cols="108" name="footer" id="footer">${config.footer }</textarea></td>
				</tr>
				<tr>
					<td class="text-right">公告内容：</td>
					<td><textarea rows="8" cols="108" name="notice" id="notice">${config.notice }</textarea></td>
				</tr>
			</table>
			</form>
		</div>
	</div>
	<div style="text-align: center;margin-top:20px;">
				<a class="btn btn-success" onclick="saveType();" >保存</a>
				<a class="btn btn-primary" onclick="reSet();" >重置</a>
			</div>
	</section>
	<script src="js/jquery-1.9.1.js"></script>
	<script src="js/layer/layer.js"></script>
	<script type="text/javascript">
		function reSet(){
			$("#title").val("");$("#freetimes").val("");$("#appid").val("");
			$("#appkey").val("");$("#continue_fee").val("");$("#notice").val("");
		}
		function saveType(){
			$.ajax({
				async : false,
				cache : false,
				type : 'post',
				dataType : "json",
				data : $("#typeForm").serialize(),
				url : "admin/save_config",// 请求的action路径
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("请求失败！");
				},
				success : function(data) {
					if(data.state=='1'){
						layer.msg(data.message);
					}else{
						layer.msg(data.message);
					}
				}
			});	
		}
	</script>
</body>
</html>